package com.demo.controller;

import com.demo.service.AsyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Chen Wei
 * @date 2020-12-29 11:29
 */
@RestController
@Slf4j
public class Hello {
    @Autowired
    private AsyncService asyncService;

    @RequestMapping("/")
    public String submit() {
        log.info("start submit");
        //调用service层的任务
        asyncService.executeAsync();
        log.info("end submit");
        return "success";
    }

    @RequestMapping("/submit100")
    public void submit100() {
        for (int i = 0; i < 10; i++) {
            log.info("start submit");
            //调用service层的任务
            asyncService.executeAsync();
            log.info("end submit");
        }
    }
}
